<template>
	<view class="content">
		<view class="box">
			<view class="temple">
				<view class="temple-item" v-for="item in templeList">
					<view class="temple-item-left">
						<view class="temple-title">
							{{ item.name }}
						</view>
						<view class="temple-position">
							<view class="img">
								<text class="icon-position iconfont" style="font-size: 36rpx;"></text>
							</view>
							<view class="text">
								{{ item.address }}
							</view>
						</view>
					</view>
					<view class="temple-item-right">
						<u-image width="40rpx" height="40rpx" src="/static/img/temple_details.png" @click="goTempleDetails(item.temple_id)"></u-image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				templeList: [],
				paging:{
					page: 1,
					limit: 10,
				},
				total: null
			}
		},
		onLoad() {
			this.getTempleList()
		},
		onReachBottom() {
			this.getTempleList()
		},
		onPullDownRefresh() {
			uni.startPullDownRefresh({
				success: () => this.refresh(),
				complete: () => uni.stopPullDownRefresh()
			})
		},
		methods: {
			goTempleDetails(id){
				uni.navigateTo({ url: '/pages/index/temple/templeDetails?id=' + id })
			},
			getTempleList(){
				if (this.templeList.length == this.total) return
				this.$api.templeList({page:1,limit:10,status:1}).then(res => {
					this.templeList = [...this.templeList, ...res.data.list]
					this.total = res.data.total
					this.paging.page++
				})
			},
			// 刷新列表
			refresh() {
				this.paging.page = 1
				this.total = null
				this.templeList = []
				this.getTempleList()
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: url('@/static/img/bg.png');
		min-height: 100vh;
		z-index: -1;
		.box{
			padding: 30rpx;
			.temple{
				.temple-item{
					background: #FEF1DC;
					border-radius: 20rpx;
					padding: 36rpx 30rpx 28rpx 30rpx;
					display: flex;
					justify-content: space-between;
					margin-bottom: 16rpx;
					.temple-item-left{
						.temple-title{
							font-family: PingFangSC, PingFang SC;
							font-weight: 600;
							font-size: 36rpx;
							color: #111111;
							line-height: 42rpx;
							text-align: left;
							font-style: normal;
						}
						.temple-position{
							display: flex;
							padding-top: 10rpx;
							.text{
								font-family: PingFangSC, PingFang SC;
								font-weight: 400;
								font-size: 28rpx;
								color: #AAAAAA;
								line-height: 50rpx;
								text-align: left;
								font-style: normal;
							}
							.img{
								width: 32rpx;
								height: 32rpx;
							}
						}
					}
					.temple-item-right{
						padding-top: 24rpx;
					}
				}
			}
		}
	}
</style>
